package org.example.platform.beans.factory.Autoware;


import org.example.platform.beans.factory.Autoware.support.DefaultListableBeanFactory;
import org.example.platform.beans.factory.Autoware.xml.XmlBeanDefinitionReader;
import org.example.platform.beans.simple.UserService;

/**
 * 资源加载器解析文件注册对象
 */
public class Test4 {
    public static void main(String[] args) throws Exception {
        // 1.初始化 BeanFactory
        DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();

        // 2. 读取配置文件&注册Bean
        XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(beanFactory);
        reader.loadBeanDefinitions("classpath:spring.xml");

        // 3. 获取Bean对象调用方法
        UserService userService = (UserService) beanFactory.getBean("userService", UserService.class);
        String result = userService.queryUser();
        System.out.println("测试结果：" + result);
    }
}
